const express = require('express');
const router = express.Router();

// 模拟轮播图数据
const mockSwiperData = [
  {
    id: 1,
    img: '/static/images/home/swiper/1.png'
  },
  {
    id: 2,
    img: '/static/images/home/swiper/2.png'
  },
  {
    id: 3,
    img: '/static/images/home/swiper/3.png'
  }
];

// 模拟圆形图标列表数据
const mockGridRoundList = [
  {
    id: 1,
    name: '官方自营',
    badge: '准新机',
    img: '/static/images/home/grid-icon/25.png',
  }, {
    id: 2,
    name: '用户寄卖',
    badge: '已验机',
    img: '/static/images/home/grid-icon/26.png',
  }, {
    id: 3,
    name: '个人闲置',
    badge: '',
    img: '/static/images/home/grid-icon/27.png',
  }, {
    id: 4,
    name: '手机保卖',
    badge: '',
    img: '/static/images/home/grid-icon/28.png',
  }, {
    id: 5,
    name: '电脑数码',
    badge: '',
    img: '/static/images/home/grid-icon/29.png',
  }
];

// 模拟小图标列表数据
const mockGridSmList = [
  {
    id: 1,
    name: '苹果',
    img: '/static/images/home/grid-icon/30.png',
  }, {
    id: 2,
    name: '华为',
    img: '/static/images/home/grid-icon/31.png',
  }, {
    id: 3,
    name: '小米',
    img: '/static/images/home/grid-icon/32.png',
  }, {
    id: 4,
    name: 'vivo',
    img: '/static/images/home/grid-icon/33.png',
  }, {
    id: 5,
    name: 'oppo',
    img: '/static/images/home/grid-icon/34.png',
  }, {
    id: 6,
    name: '魅族',
    img: '/static/images/home/grid-icon/35.png',
  }, {
    id: 7,
    name: '寄卖优选',
    img: '/static/images/home/grid-icon/36.png',
  }, {
    id: 8,
    name: '验机特惠',
    img: '/static/images/home/grid-icon/37.png',
  }, {
    id: 9,
    name: '直播特卖',
    img: '/static/images/home/grid-icon/38.png',
  }, {
    id: 10,
    name: '更多分类',
    img: '/static/images/home/grid-icon/39.png',
  }
];

// 模拟商品分类列表数据
const mockGoodsSortListData = [
  {
    id: 1,
    quv: true,
    autarky: true,
    title: '商品标题，商品标题，商品标题，商品标题',
    type: ['全新', '全网通', '64G'],
    price: '2999',
    cost_price: '6999',
    discount: ['已降90元', '赠'],
    style: ['7天无理由', '当天发货', '180天质保'],
    img: '/static/images/home/goods/1.png',
  }, {
    id: 2,
    quv: true,
    autarky: false,
    title: '商品标题，商品标题，商品标题，商品标题',
    type: ['无拆修', '完美外观', '电池耐用'],
    price: '1699',
    cost_price: '6999',
    discount: ['赠'],
    style: ['7天无理由', '24h发货', '30天质保'],
    img: '/static/images/home/goods/2.png',
  }, {
    id: 3,
    quv: true,
    autarky: false,
    title: '商品标题，商品标题，商品标题，商品标题',
    type: ['无拆修', '完美外观', '电池耐用'],
    price: '1699',
    cost_price: '6999',
    discount: [],
    style: ['7天无理由', '24h发货', '30天质保'],
    img: '/static/images/home/goods/3.png',
  }, {
    id: 4,
    quv: true,
    autarky: true,
    title: '商品标题，商品标题，商品标题，商品标题',
    type: ['全新', '全网通', '64G'],
    price: '2999',
    cost_price: '6999',
    discount: ['已降90元', '赠'],
    style: ['7天无理由', '当天发货', '180天质保'],
    img: '/static/images/home/goods/4.png',
  }, {
    id: 5,
    quv: true,
    autarky: false,
    title: '商品标题，商品标题，商品标题，商品标题',
    type: ['无拆修', '完美外观', '电池耐用'],
    price: '1699',
    cost_price: '6999',
    discount: ['赠'],
    style: ['7天无理由', '24h发货', '30天质保'],
    img: '/static/images/home/goods/5.png',
  }, {
    id: 6,
    quv: true,
    autarky: false,
    title: '商品标题，商品标题，商品标题，商品标题',
    type: ['无拆修', '完美外观', '电池耐用'],
    price: '1699',
    cost_price: '6999',
    discount: [],
    style: ['7天无理由', '24h发货', '30天质保'],
    img: '/static/images/home/goods/6.png',
  }
];

// 获取轮播图数据
router.post('/swiperListData', (req, res) => {
  try {
    res.json({
      code: 200,
      message: 'success',
      data: mockSwiperData
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取圆形图标列表
router.post('/gridRoundList', (req, res) => {
  try {
    res.json({
      code: 200,
      message: 'success',
      data: mockGridRoundList
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取小图标列表
router.post('/gridSmList', (req, res) => {
  try {
    res.json({
      code: 200,
      message: 'success',
      data: mockGridSmList
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

// 获取商品分类列表数据
router.post('/goodsSortListData', (req, res) => {
  try {
    res.json({
      code: 200,
      message: 'success',
      data: mockGoodsSortListData
    });
  } catch (error) {
    res.status(500).json({
      code: 500,
      message: '服务器错误',
      data: null
    });
  }
});

module.exports = router;